<template>
  <div class="box">
    <avue-crud ref="crud"
               v-model="form"
               :page="page"
               :data="tableData"
               :table-loading="tableLoading"
               :option="tableOption"
               @on-load="getList"
               @search-change="searchChange"
               @refresh-change="refreshChange"
               @size-change="sizeChange"
               @current-change="currentChange"
               @row-update="handleUpdate"
               @row-save="handleSave"
               @row-del="rowDel">
      <template slot="menu" slot-scope="scope">
        <el-button :size="scope.size" icon="el-icon-s-tools" @click="createScreen(scope.row)" type="text">构建大屏</el-button>
        <el-button :size="scope.size" icon="el-icon-view" @click="viewScreen(scope.row)" type="text">浏览大屏</el-button>
      </template>
    </avue-crud>

  </div>
</template>

<script>
    import * as u from '@/util/util'
    import {tableOption} from '@/js/bus/screen/myList.js'
    import tableMixins from "@/mixins/tableMixins.vue"
    export default {
        name: "myList",
        mixins:[tableMixins],
        data() {
            return {
                //访问接口前缀
                url:"bus-screen",
                // 表格参数
                tableOption: tableOption,
                form:{
                    isEncrypt:"",
                }

            }
        },
        watch:{
          //监听form
          "form.isEncrypt":function(val){
              console.log(val);
              //动态设置是否显示密码框
              this.tableOption.column.forEach(x=>{
                    if(x.prop=='password'){
                      x.addDisplay=x.editDisplay=(val=='Y'?true:false);

                  }
              })
          }
        },
        created() {

        },
        methods: {
            //构建大屏
            createScreen(row){
                this.$router.push("/screen/"+row.id);
            },
            //预览大屏
            viewScreen(row){
                //打开
              const { href } = this.$router.resolve({
                path: '/screenView/'+row.id,
              });
              window.open(href, '_blank');
            }

        }
    }
</script>

<style scoped>

</style>
